package com.siyuan.blog;


import com.siyuan.blog.common.DruidDataSourceFactory;
import org.ponly.fs.FileSystem;
import org.ponly.fs.FileSystems;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import javax.sql.DataSource;

@SpringBootApplication
@PropertySource("classpath:config.properties")
public class BlogApplication {

	public static void main(String[] args) {
		SpringApplication.run(BlogApplication.class, args);
	}


	/**
	 * druid数据源
	 * @return
	 */
	@Bean
	public DataSource dataSource(){
		return DruidDataSourceFactory.createDataSource();
	}

	/**
	 * fs 模块配置
	 * @param environment
	 * @return
	 */
	@Bean
	public FileSystem fileSystem(Environment environment){
		return FileSystems.getFileSystem(environment.getProperty("fs.url"));
	}

}
